﻿cmake_minimum_required(VERSION 2.8)
project(libcurl)
set(CMAKE_DEBUG_POSTFIX "D")
file(GLOB_RECURSE lib_hdrs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/*.h)
file(GLOB_RECURSE lib_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} lib/*.c)
list(APPEND lib_libs ${ZLIB_LIBRARIES} ${LIBSSH2_LIBRARIES} ${OPENSSL_LIBRARIES} ws2_32 Wldap32)
include_directories(include lib ${ZLIB_INCLUDE_DIRS} ${LIBSSH2_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${LIBSSH2_SOURCE_DIR}/include ${OPENSSL_SOURCE_DIR}/../include ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(/DHAVE_CONFIG_H /DBUILDING_LIBCURL /DCURL_HIDDEN_SYMBOLS /D_USRDLL /DUSE_OPENSSL)
add_library(${PROJECT_NAME} SHARED ${lib_srcs} ${lib_hdrs} lib/${PROJECT_NAME}.rc)
target_link_libraries(${PROJECT_NAME} ${lib_libs})
install(DIRECTORY include/curl DESTINATION include)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_srcs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()

if(BUILD_APPS)
  add_subdirectory(src)
endif()
